<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>库尔勒农商银行快易贷客户管理系统-登录</title>
<link rel="stylesheet" type="text/css" href="css/styles.css"/>
</head>
<body>
<div class="htmleaf-container">
	<div class="wrapper">
		<div class="container">
			<h1>Welcome</h1>			
			<form class="form" action="#" method="post">
				<input type="text" id="username" name="username" autofocus placeholder="Username">
				<input type="password" id="password" name="password" placeholder="Password">
				<button type="button" id="login-button">Login</button>
			</form>
		</div>
		
		<ul class="bg-bubbles">
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
		</ul>
	</div>
</div>

<script src="js/jquery-2.1.1.min.js" type="text/javascript"></script>
<script src="js/jquery.base64.js" type="text/javascript"></script>
<script>
$('#login-button').click(function (event) {
	
	var username = $("#username"), password = $("#password");
	var user_id = $.base64.btoa(username.val());
	if(user_id.length>25){
		alert("请输入正确的用户名");
		return ;
	}
	if(password.val()==''){
		alert("请输入密码");
		return ;
	}
	var pwd = $.base64.btoa(password.val());
	var data = {
		"username" : user_id,
		"password" : pwd,
	};
	$.ajax({
		beforeSend : function() {
			$('form').fadeOut(200);
			$('.wrapper').addClass('form-success');
		},
		type : "post",
		url :"/Login/login",
		dataType : "json",
		contentType : "application/json",
		data : JSON.stringify(data),
		success : function(data) {
			$("#loadgif").fadeOut(100);
			if (data.code == "200"&&data.data) {
				location.href = "/admin";
			} else {
				alert(data.message);
			}
		},
		error : function(data) {
			$('form').fadeOut(100);
			console.log("错误");
		}
	})
});
</script>
</body>
</html>